cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(boopt LANGUAGES CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/modules")
include(color)
define_colors()
option(USE_STATIC_LIBRARY "Compile sources into a static library" ON)
option(BUILD_GTEST_CASES "Build Gtest case" ON)

if (USE_STATIC_LIBRARY)
	message("${BoldYellow}Compile sources into a ${BoldRed}static${BoldYellow} library...${ColourReset}")
else()
	message("${BoldYellow}Compile sources into a ${BoldGreen}static${BoldYellow} library...${ColourReset}")
endif()

add_library(boopt INTERFACE)
target_include_directories(boopt INTERFACE "${CMAKE_CURRENT_LIST_DIR}/boopt")

if (BUILD_GTEST_CASES)
	find_package(GTest REQUIRED)
	find_package(Threads REQUIRED)
	add_executable(gtest_case "")
	target_sources(gtest_case
	  PRIVATE
	  	${CMAKE_CURRENT_LIST_DIR}/test/gtest_case.cpp
	)
	target_link_libraries(gtest_case
	  PRIVATE
	    boopt
	    gtest
	  	gtest_main
		Threads::Threads
	)

	enable_testing()
	add_test(
		NAME Gtest_case
		COMMAND $<TARGET_FILE:gtest_case>
	)
endif()